
let data = {
    a: 700,    // "白值"
    b: 46.6 + 30 + 50,    // "攻击百分比"
    c: 350,    // "攻击固定值",
    attack: 622,   // 攻击力  程序会根据上边的计算攻击力 如果你想直接用某个攻击力计算后续值,在这里填写(只要这里的值不是0 会优先用这里的值)
    d: 17,    // "暴击"
    e: 75,    // "爆伤"
    f: 14.4,    // "增伤"
    g: 4.44,    // "技能倍率"
    h: 0,    // "减抗"
    i: 10,    // "敌人抗性"
    j: 50,    // "你的等级" 
    k: 90,    // "敌人等级"
    l: 0,    // "减防",
    m: 1,     // 元素反应倍率   
    n: 1   // 精通增伤 
}

console.log("平均期望:" + getPoint(data)) 
console.log(Object.entries(getDMG(data)).map(v=>v.join(":")).join("\n") ) 

function getPoint(props){
    let {a,b,c,d,e,f,g,h,i,j,k,l,m,n,attack} = props;
    attack = attack || (a*(1+b/100)+c)
    let fyk = m * n;
    if(m <= 1){fyk = 1}
    return attack*(1-((d>100?100:d)/100)+((d>100?100:d)/100)*(1+e/100))*(1+f/100)*g*q(i-h)*df(j,k,l)*fyk
}

function getDMG(props){
    let {a,b,c,d,e,f,g,h,i,j,k,l,m,n,attack} = props;
    attack = attack || (a*(1+b/100)+c)
    let fyk = m * n;
    if(m <= 1){fyk = 1}
    return {
        "暴击":attack*(1 + e/100)*(1+f/100)*g*q(i-h)*df(j,k,l)*fyk,
        "未暴击": attack*(1+f/100)*g*q(i-h)*df(j,k,l)*fyk
    }
}

function q (resistance) {
    if(resistance < 0) {
        return 1 - resistance/200
    } else if (resistance >=0 && resistance < 75){
        return 1 - resistance/100
    } else {
        return 1/(1+resistance/100*4)
    }
}

function df(youLv=0, eLv=0, td){
    return (100+youLv)/(100+youLv+(100+eLv)*(td? (100-td)/100 : 1))
}
